// 开发文档：https://uniapp.dcloud.io/uniCloud/clientdb?id=action
 // const uniID = require("uni-id");
module.exports = {
	before: async (state, event) => 
	{   console.log('---before----');
		console.log(state.auth);//获取用户体
		console.log(event.command);
		console.log(event.uniIdToken);//获取token
	let callFunctionResult = await uniCloud.callFunction({
			name: 'router',
			data: {
				action:'/common/user/checkToken',
				data:{}
			}
		}).then(({
			result
		}) => {
			console.log(result);
			
		}).catch(err => {
			
		})
		console.log(callFunctionResult);
	},
	after: async (state, event, error, result) => {
		 console.log('---after----');
		 console.log(state);//获取用户体
			
		 console.log(event);//获取token
		if (error) {
			throw error
		}
		return result
	}
}
// 开发文档：https://uniapp.dcloud.io/uniCloud/clientdb?id=action
// const uniID = require("uni-id");
// module.exports = {
// 	before: async (state, event) => {
// 		// 校验 token
// 		const auth = await uniID.checkToken(ctx.event.uniIdToken);
// 		if (auth.code) {
// 		  // 校验失败，抛出错误信息
// 		  throw { code: auth.code, message: auth.message };
// 		}
// 		state.auth = auth; // 设置当前请求的 auth 对象
// 		console.log(auth);
// 	},
// 	after: async (state, event, error, result) => {
// 		if (error) {
// 			throw error
// 		}
// 		return result
// 	}
// }


